package com.cn.cs;

import com.mysql.jdbc.Connection;
import com.mysql.jdbc.PreparedStatement;

import java.sql.DriverManager;

public class work5 {
        public static void main(String[] args) {
            try {
                //第一步加载驱动jar
                Class.forName("com.mysql.jdbc.Driver");
                //获取数据库的连接对象
                Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql1","root","root");
                //获取发送sql的对象
                PreparedStatement pst = (PreparedStatement) con.prepareStatement("delete from student where id=?");
                //解析占位符
                pst.setInt(1, 001);
                //执行sql获取结果
                int count = pst.executeUpdate();
                System.out.println(count > 0 ? "操作成功" : "操作失败");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

